<?php
// card id  pe2K2jueSlpaafyz1PB30pXpeInk
ini_set('display_errors', 'On');
define('APPID', 'wx3b97b20380656267');
define('SECRET', '763bc006bded748f3d88a1ccddbac1bc');
 
function get_access_token(){
	$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".APPID."&secret=".SECRET;
	$res = https_request($url, 'get', 'json');
	$access_token = $res["access_token"];
	return $access_token;
}
 
function https_request($url, $type="get", $res="json", $data = ''){
    //1.初始化curl
    $curl = curl_init();
    //2.设置curl的参数
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    if ($type == "post"){
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    }
    //3.采集
    $output = curl_exec($curl);
    //var_dump(curl_getinfo($curl));
    //4.关闭
    curl_close($curl);
    if ($res == 'json') {
        return json_decode($output,true);
    }
}
$access_token = get_access_token();
$url = "https://api.weixin.qq.com/card/batchget?access_token=".$access_token;
$data='{
  "offset": 0,
  "count": 10,
   "status_list": ["CARD_STATUS_VERIFY_OK", "CARD_STATUS_DISPATCH"]
}';
$res = https_request( $url ,'post', 'json', $data);
var_dump($res);

echo "<br />";

$url='https://api.weixin.qq.com/card/get?access_token='.$access_token;
$cardid='py4HbsyKkU0Ymt6K1rePyyl0d7gI';
$data='{
  "card_id":"'.$cardid.'"
}';
$res = https_request( $url ,'post', 'json', $data);
var_dump($res);
    
 
  


 